import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject

class StatusBar(Gtk.Statusbar):
    def __init__(self):
        super().__init__()
        self.context_id = self.get_context_id("status")
        
        # Current station label
        self.current_label = Gtk.Label()
        self.current_label.set_text("Not playing")
        self.pack_start(self.current_label, True, True, 0)
        
        # Volume indicator
        self.volume_icon = Gtk.Image.new_from_icon_name(
            "audio-volume-high", Gtk.IconSize.MENU)
        self.pack_end(self.volume_icon, False, False, 0)
    
    def update_status(self, station, volume):
        if station:
            self.current_label.set_text(f"Playing: {station['name']}")
        else:
            self.current_label.set_text("Not playing")
        
        # Update volume icon based on volume level
        if volume == 0:
            icon = "audio-volume-muted"
        elif volume < 0.33:
            icon = "audio-volume-low"
        elif volume < 0.66:
            icon = "audio-volume-medium"
        else:
            icon = "audio-volume-high"
        
        self.volume_icon.set_from_icon_name(icon, Gtk.IconSize.MENU)